from flask import Blueprint
from flask import redirect
from flask import request
from flask import session
from flask import url_for

admin_blu = Blueprint("admin", __name__, url_prefix="/admin")
from . import views


@admin_blu.before_request
def check_is_admin():
    admin = session.get("is_admin")
    if not admin and not request.url.endswith(url_for("admin.admin_login")):
        return redirect("/")
